from apps.api import create_blueprint_v1
from apps.app import Flask
from apps.config import secure, setting


def register_plugin(app):
    from apps.models.base import db
    db.init_app(app)
    with app.app_context():
        db.create_all()

def create_app():

    ginger_app = Flask(__name__)
    ginger_app.config.from_object(secure)
    ginger_app.config.from_object(setting)

    ginger_app.register_blueprint(create_blueprint_v1())

    register_plugin(ginger_app)

    return ginger_app